import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/index.vue"),
  },
  {
    path: "/search",
    name: "search",
    component: () => import("@/views/search/index.vue"),
  },
  {
    path: "/article/:articleId",
    name: "article",
    component: () => import("@/views/article/index.vue"),
    props:true //开启Props传参，说白了就是把路由参数映射到组件的props组件中
  },
  {
    path: "/",
    name: "layout", //如果父路由有默认子路由，那他的name没有意义
    component: () => import("@/views/layout/index.vue"),
    children: [
      {
        path: "",
        name: "home",
        component: () => import("@/views/home/index.vue"),
      },
      {
        path: "/qa",
        name: "qa",
        component: () => import("@/views/qa/index.vue"),
      },
      {
        path: "/video",
        name: "video",
        component: () => import("@/views/video/index.vue"),
      },
      {
        path: "/mine",
        name: "mine",
        component: () => import("@/views/mine/index.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

export default router;
